<%@ page errorPage="JSP_Error.jsp"
%><%@ page contentType="text/html; charset=UTF-8"
%><%@ page import="com.microstrategy.web.app.utils.JavaScriptBundles"
%><%@ taglib uri="/webUtilTL.tld" prefix="web" %>

<%-- Start up the Web Statistics... --%>
<web:performanceTimer action="initialize" />
<web:performanceTimer action="start" />

<%!
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // C o n s t a n t s . . .
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    // This is the URL Parameter that determines we are in "development" mode
    // or not. It is used to define how JavaScript resources are included.
    String URL_PARAM_DEVELOPMENT_MODE = "devmode";
    
    // The name of our Mojo bundle.
    String MOJO_BUNDLE_NAME = "mojo-mobile-list";
    
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    // M e t h o d s . . .
    // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    
    // This method simply generates a reference to a JavaScript file
    void includeJavaScriptFile(JspWriter out, String path) throws java.io.IOException {
    	out.println("<script src=\"" + path + "\"></script>");
    }
    
    // This method includes all of the individual (source) JavaScript files in a bundle
    void includeSourceBundleFiles(JspWriter out, String bundleName, String resPrefix) throws java.io.IOException {
    	// Get the Bundle object...
	    JavaScriptBundles.JavaScriptBundle bundle = JavaScriptBundles.getInstance().get(bundleName);
    	
    	// Check for missing bundle...
    	if (bundle == null) {
    		out.println("<!-- Unable to load bundle '" + bundleName + "' -->");
    		return;
    	}

    	// Loop through the files in the bundle...
    	for (int i=0;i<bundle.getFiles().size();i++) {
    		JavaScriptBundles.JavaScriptFile f = (JavaScriptBundles.JavaScriptFile)bundle.getFiles().get(i);
    		// Generate the inclusion of the file... 
    		includeJavaScriptFile(out, resPrefix + f.getPath() + "/" + f.getFilename());
    	}
    }
    
    // This method includes just the named bundle...
    void includeBundleFile(JspWriter out, String bundleName, String resPrefix) throws java.io.IOException {
    	try {
	    	// Get the relative path to the named bundle...
	    	String bundlePath = JavaScriptBundles.getInstance().getBundlePath(bundleName);
	    	
	    	// Construct the script to include the file...
	    	includeJavaScriptFile(out, resPrefix + bundlePath);
    	}
    	catch (IllegalArgumentException e) {
    		// Error message!
    		out.println("<!-- Unable to resolve path to bundle '" + bundleName + "' -->");
    	}
    }
%>
<%
    // Whether or not we are in "development mode".
    boolean devMode = (request.getParameter(URL_PARAM_DEVELOPMENT_MODE) != null && 
    				   Boolean.valueOf(request.getParameter(URL_PARAM_DEVELOPMENT_MODE)).booleanValue()) || 
    				   false; /* Change this 'false' to 'true' to have it on by default! */
    
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >

<html>
  <head>
    <title><web:descriptor key="mstrWeb.7837" desc="Mobile Configuration Page" /></title>
    <link href="../javascript/mojo/css/mobileconfig.css" type="text/css" rel="stylesheet"/>
    <link href="../javascript/mojo/css/MCListbox.css" type="text/css" rel="stylesheet"/>
    <link href="../javascript/mojo/css/core.css"  type="text/css"  rel="stylesheet" />
    <link href="../javascript/mojo/css/colorPicker.css"  type="text/css"  rel="stylesheet" />
    <link href="../javascript/mojo/css/buttonPreview.css"  type="text/css"  rel="stylesheet" />
  </head>
  <body>
     <web:ifFeature name="IE6">
      <web:then>
        <web:descriptor key="mstrWeb.7912" desc="This feature is not supported by the current browser. Refer to the MicroStrategy Mobile Readme file for a list of supported browsers." />
      </web:then>
      <web:else>
         <div id="mobileConfigView"></div>
      </web:else>
     </web:ifFeature>
  </body>
  
  <script type="text/javascript">
    var mstrApp = {
        name: '<web:value type="config" name="servletDeploymentName"/>',
        jsRoot: '../javascript/',
        jsMojoRoot: '../javascript/mojo/js/source/',
        localeId: '<web:connectionValue property="locale"/>',
        displayLocaleId: '<web:connectionValue property="displayLocaleID"/>',
        mstrDescs: <web:bundleDescriptor name="mojo-mobile-list"/>,
        taskURL: '<web:taskProcessorName/>'
    };
  </script>
  <%-- Include the Mojo JavaScript bundle! --%>
  <web:ifFeature name="IE6">
      <web:then>
      </web:then>
      <web:else>
      <%--	if (devMode) {
	    	    // Include all of the individual JavaScript files...
		       includeSourceBundleFiles(out, MOJO_BUNDLE_NAME, "");
	        } else {
		       // Include just the Bundle!
		       includeBundleFile(out, MOJO_BUNDLE_NAME, "../");
	        }
      --%>
      </web:else>
  </web:ifFeature>
  <!--
  <script src="../javascript/mojo/js/source/mstrmojo.js"></script>
  <script src="../javascript/mojo/js/source/publisher.js"></script>
  <script src="../javascript/mojo/js/source/hash.js"></script>
  <script src="../javascript/mojo/js/source/array.js"></script>
  <script src="../javascript/mojo/js/source/_Provider.js"></script>
  <script src="../javascript/mojo/js/source/_LoadsScript.js"></script>
  <script src="../javascript/mojo/js/source/_HasChildren.js"></script>
  <script src="../javascript/mojo/js/source/_HasBindings.js"></script>
  <script src="../javascript/mojo/js/source/_CanValidate.js"></script>
  <script src="../javascript/mojo/js/source/registry.js"></script>
  <script src="../javascript/mojo/js/source/VBox.js"></script>
  <script src="../javascript/mojo/js/source/HBox.js"></script>
  <script src="../javascript/mojo/js/source/Label.js"></script>
  <script src="../javascript/mojo/js/source/TextBox.js"></script>
  <script src="../javascript/mojo/js/source/DropDownList.js"></script>
  <script src="../javascript/mojo/js/source/_ListSelections.js"></script>
  <script src="../javascript/mojo/js/source/_ListBase2Selections.js"/></script>
  <script src="../javascript/mojo/js/source/SelectBox.js"></script>
  <script src="../javascript/mojo/js/source/Xhr.js"></script>
  <script src="../javascript/mojo/js/source/mobileList.js"></script>
  <script src="../javascript/mojo/js/source/mobileListModel.js"></script>
  -->
  <web:ifFeature name="IE6">
      <web:then>
      </web:then>
      <web:else>
          <script src="../javascript/bundles/mojo-mobile-list.js"></script>
      </web:else>
  </web:ifFeature>
  <%-- Trigger the collection of Web Statistics --%>
  <web:logging action="statistics" />
</html>

